package com.ext.aic.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.recyclerview.widget.RecyclerView;

import com.ext.aic.R;
import com.ext.aic.adapter.binder.ContentItemBinder;
import com.ext.aic.beans.ProductItem;
import com.ext.aic.databinding.ContentCenterItemBinding;
import com.ext.aic.holder.ContentCenterViewHolder;

import java.util.List;

import lombok.Setter;

public class ContentCenterListAdapter extends RecyclerView.Adapter<ContentCenterViewHolder> {

    @Setter
    private List<ProductItem> items = null;
    private ContentItemBinder binder;

    public ContentCenterListAdapter(Context context) {
        this.binder = new ContentItemBinder(context);
    }

    @Override
    public ContentCenterViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.content_center_item, parent, false);
        return new ContentCenterViewHolder(ContentCenterItemBinding.bind(view));
    }

    @Override
    public void onBindViewHolder(ContentCenterViewHolder holder, int position) {
        ProductItem productItem = items.get(position);
        binder.bind(holder, productItem, position);
    }

    @Override
    public int getItemCount() {
        return items.size();
    }
}
